<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>sweetalert2-插件的基本使用</title>
        <link rel="stylesheet" href="css/sweetalert2.min.css" />
    </head>
    <body>
        <h1>SweetAlert2 使用教程</h1>
        <div id="question">问题</div>
        <p>来源:<a href="http://www.cnblogs.com/beiz/p/5238124.html">http://www.cnblogs.com/beiz/p/5238124.html</a></p>
        <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
        <script src="js/sweetalert2.min.js"></script>
        <script>
            $("#question").click(function(){
                swal({
                    type:'warning',
                    title:'Are you continue?',
                    text:'You will not be able to recover this imaginary file!',
                    // showConfirmButton:true,
                    showCancelButton:true,
                    confirmButtonText:'Yes,delete it!',
                    cancelButtonText:'No,keep it!',
                }).then(function(isConfirm){
                    if(isConfirm === true){
                        swal(
                          'Deleted!',
                          'Your imaginary file has been deleted.',
                          'success'
                        );
                    }
                    else if (isConfirm === false) {
                        swal(
                            'Cancelled',
                            'Your imaginary file is safe :)',
                            'error'
                        );                      
                    } else {
                        // Esc, close button or outside click
                        // isConfirm is undefined
                    }
                })
            });
        </script>
    </body>
</html>